package com.wh;

import com.wh.parser.Parser;
import com.wh.tokenizer.CharReader;
import com.wh.tokenizer.TokenList;
import com.wh.tokenizer.Tokenizer;

import java.io.IOException;
import java.io.StringReader;

public class JSONParser {

    private Tokenizer tokenizer = new Tokenizer();

    private Parser parser = new Parser();

    public Object fromJSON(String json) throws IOException {
        CharReader charReader = new CharReader(new StringReader(json));
        TokenList tokens = tokenizer.tokenize(charReader);
        return parser.parse(tokens);
    }

    public static void main(String[] args) throws IOException {
        Object res = new JSONParser().fromJSON("123");
        Object res2 = new JSONParser().fromJSON("{\"name\":\"王吟\",\"age\":21,\"sex\":false}");
    }
}
